@tool
class_name ContextBehavior_Wander
extends BaseContextBehavior

#region 属性
@export var force:float
@export var offest:float
@export var radius:float
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
func init():
	super()
func calc_steering(behaviors_owner:Node,agent:SteeringBehaviorAgent,delta:float):
	super(behaviors_owner,agent,delta)
	var dir = agent.get_vel().normalized() * offest + Utils.get_random_point_on_circle(Vector2.ZERO,radius)
	dir = dir.normalized()
	var interest = dir * sensitive
	agent.add_linear_force_interest(interest * force)
#endregion
#region 公共方法
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _init() -> void:
	if Engine.is_editor_hint():
		resource_local_to_scene = true
	behavior_type = GameEnum.ContextBehaviorType.Wander
func draw() -> void:
	super.draw()
	var dir = Vector2(1,0) if agent.get_vel().length() < 1 else agent.get_vel()
	GameSteeringBehaviorDebug.draw_line(agent.global_position,agent.global_position + dir.normalized() * offest,Color.BLUE)
	GameSteeringBehaviorDebug.draw_circle(agent.global_position + dir.normalized() * offest,2,Color.RED)
	GameSteeringBehaviorDebug.draw_circle(agent.global_position + dir.normalized() * offest,radius,Color.GREEN,false)
#endregion
